import React, { useState } from 'react';

import { Switch } from 'antd-mobile';
import styles from './index.module.less';
const WidgetSwitch = (props: any) => {

  const {
    onChange,
    value:propsValue

  } = props;

  const [checked, setChecked] = useState(propsValue);
  const handleChange = (checked) => {
    setChecked(checked);
    onChange && onChange(checked);
  };
  
  return (
    <div className={styles.switchWrap}>
      <Switch
        checked={checked} 
        onChange={handleChange}
      />
    </div>
  );
};

export default WidgetSwitch;
